import 'package:flutter/material.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';

class CustomSwitch extends StatelessWidget {
  final bool value;
  final ValueChanged<bool>? onChanged;
  final Color activeColor;
  final Color inactiveColor;
  final Color activeThumbColor;
  final Color inactiveThumbColor;

  const CustomSwitch({
    Key? key,
    required this.value,
    this.onChanged,
    this.activeColor = InmotionThemeColor.inmotion6,
    this.activeThumbColor = Colors.white,
    this.inactiveColor = GrayColor.gray4,
    this.inactiveThumbColor = InmotionThemeColor.inmotion6,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 32, // 固定高度，可根据实际需求调整
      child: Transform.scale(
        scale: MediaQuery.of(context).size.width / 375 * 0.9,
        child: Switch(
          value: value,
          onChanged: onChanged,
          activeColor: activeColor,
          activeTrackColor: activeColor.withOpacity(0.9),
          inactiveThumbColor: inactiveThumbColor,
          inactiveTrackColor: inactiveColor,
          thumbColor: MaterialStateProperty.resolveWith<Color>(
            (Set<MaterialState> states) {
              if (states.contains(MaterialState.selected)) {
                return activeThumbColor;
              }
              return inactiveThumbColor;
            },
          ),
        ),
      ),
    );
  }
}
